package com.cremamobile.filemanager;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.preference.Preference;
import android.util.AttributeSet;

public class VersionPreference extends Preference {
    public VersionPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        String content = context.getResources().getString(R.string.version);
        String versionName = "";
        final PackageManager packageManager = context.getPackageManager();
        if (packageManager != null) {
            try {
                PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
                versionName = " v"+packageInfo.versionName;
            } catch (PackageManager.NameNotFoundException e) {
            }
        }
        setTitle(content + versionName);
    }
}